#!/bin/bash
# Updates the version to that specified
# Input: new version number
# Output: none (files containing version numbers updated)

# exit on error
set -e

old_version=$(grep "^VERSION = " ../kisa.pro | grep --only-matching "[0-9\.].*")

new_version=$1

if [[ -z $new_version ]]; then
  echo "Need a new version number!"
  echo "Old version is $old_version"

  exit 1
fi

echo "Old version: $old_version"
echo "New version: $new_version"

sed_cmd="sed --in-place --expression="s/$old_version/$new_version/g""

$sed_cmd ../kisa.kdevelop
$sed_cmd ../kisa.pro
$sed_cmd doc/README
$sed_cmd doc/kisa_index.html
$sed_cmd doc/user_manual.html
$sed_cmd create_src_package.sh
$sed_cmd doxyfile
$sed_cmd DEBIAN/control
$sed_cmd create_deb_package.sh
$sed_cmd ../src/kisa.cpp
$sed_cmd ../src/lib/kisalib.cpp
$sed_cmd ../src/lib/lib.pro
$sed_cmd ../src/src.pro
